import Vue from "vue";
import VueRouter from "vue-router";
import Main from "../views/Main"
import Login from "../views/Login";
import Error404 from "../components/error404"
import left from "../components/left";
import top from "../components/top";
import createUser from "../views/crud/createUser";
import deleteUser from "../views/crud/deleteUser";
import updateUser from "../views/crud/updateUser";
import selectUser from "../views/crud/selectUser";
import tables from "../components/tables";
import shop from "../views/shop/shop";
import tree from "../components/tree";
import productManger from "../views/product/productManger";
//安装路由
Vue.use(VueRouter);

//导出路由
export default new VueRouter({
  //配置url没有#
  mode:'history',
  routes:[
    {
      //路由路径
      path:"/",
      //取名字
      name:"",
      //跳转的组件
      component:Login,
      meta: {
        requireAuth: false
      }
    },
    {
      //路由路径
      path:"/login",
      //取名字
      name:"login",
      //跳转的组件
      component:Login,
      meta: {
        requireAuth: false
      },
    },
    {
      //配置404页面
      path:"*",
      name:"error",
      component:Error404,
      meta: {
        requireAuth: true
      },
    },
    {
      //路由路径
      path:"/main",
      //取名字
      name:"main",
      //跳转的组件
      component:Main,
      meta: {
        requireAuth: true
      },
      children:[
        {
          path:"/left",
          name:"left",
          component:left,
          meta: {
            requireAuth: true
          },
        },
        {
          path:"/top",
          name:"top",
          component:top,
          meta: {
            requireAuth: true
          },
        },
        {
          path:"/tables",
          name:"tables",
          component:tables,
          meta: {
            requireAuth: true
          },
        },
        {
          path:"/createUser",
          name:"createUser",
          component:createUser,
          meta: {
            requireAuth: true
          },
        },
        {
          path:"/deleteUser",
          name:"deleteUser",
          component:deleteUser,
          meta: {
            requireAuth: true
          },
        },
        {
          path:"/updateUser",
          name:"updateUser",
          component:updateUser,
          meta: {
            requireAuth: true
          },
        },
        {
          path:"/selectUser",
          name:"selectUser",
          component:selectUser,
          meta: {
            requireAuth: true
          },
        },
        {
          path:"/shop",
          name:"shop",
          component:shop,
          meta: {
            requireAuth: true
          },
        },
        {
          path:"/tree",
          name:"tree",
          component:tree,
          meta: {
            requireAuth: true
          },
        },
        {
          path:"/productManger",
          name:"productManger",
          component:productManger,
          meta: {
            requireAuth: true
          },
        },
      ]
    },

  ],
});
